<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-->
<html>
<head>
<title>New blog</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
{% load staticfiles %}
<link rel="stylesheet" href="{% static "css/base.css" %}" type="text/css" media="screen"/>

<style type="text/css">
.layout{
position:absolute;
bakground-color:green;
margin-top:2em;
margin-left:17em;
margin-bottom:15em; 
}

td{
padding: 20px;
}
</style>

<script type="text/javascript">
	function validateForm(){
		var x = document.forms["newblog"]["title"].value;
		var y = document.forms["newblog"]["content"].value;
		if (x==null || x==""){
  		alert("Enter the title of the blog.");
  		return false;
  		}
  		else if (y==null || y == ""){
  		alert("You have not written anything yet.");
  		return false;
  		}
	}
	
	function logout()
	{
		window.location="/logout/";

	}
	
	function home(){
		window.location="/blogit/viewblog/";
	}
</script>

<!-- Script to load the text editor -->
<!-- OF COURSE YOU NEED TO ADAPT NEXT LINE TO YOUR tiny_mce.js PATH -->
<script type="text/javascript" src="/home/rachana/myblog/theblog/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        plugins : "fullpage",
        theme_advanced_buttons3_add : "fullpage"
		});
</script> <!-- script to load the editor ends here. -->
</head>
<body>
	<div>
		Welcome, {{username}}<img src="{% static "images/settings.gif"%}">
		<button type="button" onclick="logout()" align="right">Logout</button>	
		<hr>	
	</div>

<form action="/theblog/submit/" method="POST" name="newblog" onsubmit="return validateForm()">{% csrf_token %}
	<div class="layout">
	<table class="thetable">
	<tr align="center">
		<td>Blog Title <input type="text" name="title" size="60"></td>
	</tr>
	<tr align="center">
		<td><textarea rows="18" cols="100" name="content"></textarea></td>
	</tr>
	<tr>
		<td>
			<div align="center">Upload a picture: <input type="file" name="user_image"><button>Upload</button></div>
		</td>
	</tr>
	<tr align="center">
		<br><br>
		<td><input type="submit" value="Save"><button type="button" onclick="home()">Cancel</button></td>
	</tr>
	</table>
	</div>
</form>
</body>

<html>
